<%@ page import="wtc.stu.dao.StuDaoDepartment" %>
<%@ page import="wtc.stu.entity.StuEntity" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 马可
  Date: 2022/10/28
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" href="css/options.css" type="text/css">
    <link rel="stylesheet" href="css/tableFour.css" type="text/css">
    <title>系别信息管理</title>
</head>
<body>
<%--信息一览功能--%>
<div class="table">
    <table>
        <caption>系别信息一览</caption>
        <thead>
        <tr>
            <th>系别编号</th>
            <th>系别名称</th>
            <th>系别备注</th>
            <th>操作选项</th>
        </tr>
        </thead>
        <%--从数据库获取上述字段的数据--%>
        <%
            // 通过对应类的getAll方法从数据库获取数据并存储到列表当中，遍历列表以获取各字段的数据
            StuDaoDepartment daoDepartment = new StuDaoDepartment();
            List<StuEntity> ar = daoDepartment.getAll();
            for (StuEntity stuEntity : ar) {
        %>
        <tbody>
        <tr>
            <td><%=stuEntity.getXid() %>
            </td>
            <td><%=stuEntity.getXname() %>
            </td>
            <td><%=stuEntity.getXremark() %>
            </td>
            <%--通过a标签传值到指定的servlet当中，以获取要删除的数据的编号--%>
            <td class="xg"><a href="departmentServlet.jsp?delXid=<%=stuEntity.getXid()%>">删除</a></td>
            <%
                }
            %>
            <td style="display: none"></td>
        </tr>
        <tr>
            <td colspan="4" align="center" class="options"><a href="#add">增加系别信息</a></td>
        </tr>
        </tbody>
    </table>
</div>
<%--增加功能--%>
<div class="insert">
    <%--通过form表单将输入的数据传递到指定servlet当中--%>
    <form method="post" action="departmentServlet.jsp">
        <span id="add">增加系别信息</span>
        <label>
            <input type="text" name="xid" placeholder="系别编号" class="input_box"
                   oninput="value=value.replace(/\D/g,'')">
        </label>
        <label>
            <input type="text" name="xname" placeholder="系别名称" class="input_box">
        </label>
        <label>
            <input type="text" name="xremark" placeholder="系别备注" class="input_box">
        </label>
        <label>
            <input type="submit" value="提交" class="button_box">
        </label>
    </form>
</div>
<div class="update">
    <%--通过form表单将输入的数据传递到指定servlet当中--%>
    <form method="post" action="departmentServlet.jsp">
        <span id="ud">修改系别信息</span>
        <label>
            <%--从数据库获取数据作为选项--%>
            <select class="select" name="newXid">
                <option selected hidden disabled>-请选择要修改的系别编号-</option>
                <%
                    StuDaoDepartment daoDepartmentUpdate = new StuDaoDepartment();
                    List<StuEntity> arUpdate = daoDepartmentUpdate.getAll();
                    for (StuEntity stuEntity : arUpdate) {
                %>
                <option value="<%=stuEntity.getXid()%>"><%=stuEntity.getXid()%>
                </option>
                <%
                    }
                %>
            </select>
        </label>
        <label>
            <input type="text" name="newXname" placeholder="修改后的系别名称" class="input_box">
        </label>
        <label>
            <input type="text" name="newXremark" placeholder="修改后的系别备注" class="input_box">
        </label>
        <label>
            <input type="submit" value="提交" class="button_box">
        </label>
    </form>
</div>
</body>
</html>
